package com.woniu.user.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.entity.Result;
import com.woniu.user.pojo.CarBrand;
import com.woniu.user.service.ICarBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 车辆品牌表 前端控制器
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/car-brand")
@Api(tags = "汽车品牌控制类")
public class CarBrandController {

    @Autowired
    private ICarBrandService carBrandService;

    @GetMapping("/list/hot")
    @ApiOperation("展示热门汽车品牌")
    public Result<List<CarBrand>> listHotBrand(){
        QueryWrapper<CarBrand> wrapper = new QueryWrapper<>();
        wrapper.eq("is_hot", "1");
        wrapper.orderByAsc("first_word");
        List<CarBrand> carBrands = carBrandService.list(wrapper);
        return Result.ok(carBrands);
    }

    @GetMapping("/list/all")
    @ApiOperation("展示所有汽车品牌")
    public Result<List<CarBrand>> listAll(){
        QueryWrapper<CarBrand> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("first_word");
        List<CarBrand> carBrands = carBrandService.list(wrapper);
        return Result.ok(carBrands);
    }

}
